// XMLNode.h: interface for the CXMLNode class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_XMLNODE_H__7E2A5616_72AB_40CE_9111_D762B8538126__INCLUDED_)
#define AFX_XMLNODE_H__7E2A5616_72AB_40CE_9111_D762B8538126__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "mystring.h"
#include <list>
#include "XMLAttribute.h"
//#include "IpCamXml_Codec.h"
#include "base.h"
using namespace std;
class CXMLNode;
typedef list<CXMLNode *> CXMLNodeList;
class BASE_API CXMLNode  
{
public:
	const CXMLNode * FindNode(const char *pname)const;
	void Print();
	int DelNode(int num);
	int FindNodeNameNum(const char *pname);
	int FindNodeNum();
	const CXMLNode * GetNumNode(int num);
	const CXMLNode * FindSpecifyNode(const char *pname, int num);
	int Parse(CXMLNode *pparent,const char *pbuf,int len);
	int Encode(char *, int, char);  //encode this node and sub-nodes....  lxt
	const mystring &GetName()const{return m_strName;};
	const mystring &GetValue()const{return m_strValue;};
	void SetName(const char *pname){m_strName = pname;};
	void SetValue(const char *pvalue){m_strValue = pvalue;};
	const char* GetAttributeValue(const char *pname)const;
	const list<CXMLNode*> &GetChildList()const{return m_ChildList;};
	CXMLNode();
	CXMLNode(const CXMLNode &node){*this = node;};
	CXMLNode(const char *pname,const char *pvalue){m_pParent = NULL;m_strName = pname;m_strValue = pvalue;};
	char* outputXML(char* pStart, char* pEnd);
	void AddAttribute(CXMLAttribute attr);
	void ClearAttribute();
	void AddNode(CXMLNode *node);
	void SetParentNode(CXMLNode *node);
	virtual ~CXMLNode();
	CXMLNode& operator=(const CXMLNode& other)
	{
		this->m_pParent = other.m_pParent;
		this->m_strName = other.m_strName;
		this->m_strValue = other.m_strValue;
		return *this;
	};
	//bool operator==(const CXMLNode& other) const;
	//bool operator!=(const CXMLNode& other) const;
private:
	mystring			m_strName;
	mystring			m_strValue;
	list<CXMLAttribute>	m_AttributeList;
	CXMLNode*			m_pParent;
public:	
	list<CXMLNode*>		m_ChildList;
};

#endif // !defined(AFX_XMLNODE_H__7E2A5616_72AB_40CE_9111_D762B8538126__INCLUDED_)
